﻿<?php
if (!file_exists("./include/data/install.lock")){
	header("Content-type:text/html;charset=utf-8");
	echo '<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <title>程序安装 - 尘埃修复版秒赞-最稳定的秒赞</title>
    <!--baidu-->
    <meta name="baidu-site-verification" content="4IPJiuihDj" />
    <!-- Bootstrap -->
    <link href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.css" rel="stylesheet">
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
	<style>
	body{
		margin: 0 auto;
		text-align: center;
	}
	.container {
	  max-width: 580px;
	  padding: 15px;
	  margin: 0 auto;
	}
	</style>
	<script type="text/javascript">
	  function getValue(obj,str){
	  var input=window.document.getElementById(obj);
	  input.value=str;
	  }
  </script>
</head>
<body>
<div class="container">
您还未安装程序<br />3秒后自动跳转...<br />若无法跳转请<a href="install.php">刷新</a>！<meta http-equiv="refresh" content="3;url=install.php"><br />
<hr>
<p style="text-align:center">&copy;WNYR <a href=""></a></p><p></p></div>
</body>
</html>';
	exit();
}
require_once './include/common.php';
$title="控制台";
include ('include/head.php');
$ex='<div class="header">
        <ul class="nav nav-pills pull-right" role="tablist">
          <li role="presentation" class="active"><a href="index.php">首页</a></li>
          <li role="presentation"><a href="index.php?action=my">用户中心</a></li>
          <li role="presentation"><a href="login.php?action=logout">退出</a></li>
        </ul>
        <h3 class="text-muted" align="left">用户中心</h3>
      </div><hr>';
	  
if(isset($_COOKIE['w_user'])&&isset($_COOKIE['w_userid'])){
	$w_user=daddslashes($_COOKIE['w_user']);
	$sql = "SELECT * FROM w_user WHERE username='{$w_user}'";
	$sth = $db->query($sql);
	$result = $sth->fetch();
	
	if($_GET['action'] == "jh"){
	echo $ex;
	$uid=$result[id];
	$time=date("Y-m-d H:i:s"); 
		$jhkey=$_POST['jhkey'];
		$sql = "SELECT * FROM `w_jh` WHERE `key` = '{$jhkey}'";
		$sth = $db->query($sql);
		$jh = $sth->fetch();
		if($jh){
			if($jh[zt]){
				echo '激活码已使用请联系管理员';
			}else{
				$dsql = "UPDATE `w_jh` SET `zt`='1',`time`='{$time}',`uid`='{$uid}' WHERE `key` = '{$jhkey}'";
				$do = $db->exec($dsql);

				if($do){ 
				$sql = "UPDATE `w_user` SET `jh`='1' WHERE id='{$uid}'";
				$d = $db->exec($sql);
				if($d){ 
				echo '激活成功，3秒后跳转...<br />若无法跳转请<a href="index.php">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php">';
				}else{
				echo '激活失败请联系管理员！';
				}
				}else echo '激活失败请联系管理员！';
			}
		}else{
			echo '激活码错误，3秒后跳转...<br />若无法跳转请<a href="index.php">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php">';
		}
	include ('include/foot.php');
	exit;
	}
	
	if($result[jh]!=1){
		echo $ex.'<h3>账户未激活</h3><p>尊敬的用户<a href="index.php?action=my">'.$w_user.'</a>，你好！</p><p>您账户未激活，激活后方可使用，谢谢！<a href="i.php?do=jh">点击获取激活码</a></p>
  <div class="row">
   <form action="index.php?action=jh" class="form-sign" method="POST">
    <div class="input-group">
      <input type="text" class="form-control" name="jhkey" placeholder="">
      <span class="input-group-btn">
        <input class="btn btn-primary" type="submit" value="激活">
      </span>
    </div>
   </form>
  </div>';
		include ('include/foot.php');
		exit;
	}
	
	
	
	if($_COOKIE['w_userid']!=userid($result[username],$key,$result[pwd])){
		setcookie("w_user", "", time()-3600*24*30);
		setcookie("w_userid", "", time()-3600*24*30);
		echo $ex.'登陆信息有误，3秒后跳转到登陆页...<br />若无法跳转请<a href="login.php">点击这里进入</a><meta http-equiv="refresh" content="3;url=login.php">';
		include ('include/foot.php');
	}else{
	
		if($_GET['action'] == "my"){
			$regtime=time_data($result[regtime]);
			$viptime=($result[vip]!=100)?time_data($result[viptime]+$result[vip]*86400*30):"永久";
			$email=substr_replace($result[email],'***','1','3');
			if($result[vip]){
				$vip="VIP会员";
				$gq_num="10";
			}else{
				$vip="普通会员";
				$gq_num="1";
			}
			echo <<<HTML
			{$ex}
			<h3>用户信息</h3>
			<p>
			<div class="input-group"><span class="input-group-addon">用户ＩＤ</span>
			<input type="text" class="form-control" value="{$result[id]}" disabled=ture>
			</div>
			<div class="input-group"><span class="input-group-addon">用户名称</span>
			<input type="text" class="form-control" value="{$result[username]}" disabled=ture>
			</div>
			<div class="input-group"><span class="input-group-addon">ＱＱ号码</span>
			<input type="text" class="form-control" value="{$result[qq]}" disabled=ture>
			</div>
			<div class="input-group"><span class="input-group-addon">手机号码</span>
			<input type="text" class="form-control" value="{$result[tel]}" disabled=ture>
			</div>
			<div class="input-group"><span class="input-group-addon">电子邮箱</span>
			<input type="text" class="form-control" value="{$email}" disabled=ture>
			</div>
			<div class="input-group"><span class="input-group-addon">会员身份</span>
			<input type="text" class="form-control" value="{$vip}" disabled=ture>
			</div>
			<div class="input-group"><span class="input-group-addon">号码配额</span>
			<input type="text" class="form-control" value="{$gq_num}" disabled=ture>
			</div>
			<div class="input-group"><span class="input-group-addon">账户余额</span>
			<input type="text" class="form-control" value="{$result[rmb]}" disabled=ture>
			</div>
			<div class="input-group"><span class="input-group-addon">到期时间</span>
			<input type="text" class="form-control" value="{$viptime}" disabled=ture>
			</div>
			<div class="input-group"><span class="input-group-addon">注册时间</span>
			<input type="text" class="form-control" value="{$regtime}" disabled=ture>
			</div>
			</p>
			<p><a href="index.php?action=setpwd" class="btn btn-info btn-block">修改密码</a>
			<a href="index.php?action=setinfo" class="btn btn-info btn-block">修改资料</a><br>
			<a href="login.php?action=logout" class="btn btn-danger btn-block">退出登录</a></p>
			<a href="index.php" class="btn btn-primary btn-block">返回管理中心</a>
			
HTML;
			include ('include/foot.php');
			exit;
		}
		
		
		//
		if($_GET['action'] == "setpwd"){
			echo <<<HTML
			<div class="header">
				<ul class="nav nav-pills pull-right" role="tablist">
					<li role="presentation" class="active"><a href="index.php">首页</a></li>
					<li role="presentation"><a href="index.php?action=my">用户中心</a></li>
					<li role="presentation"><a href="login.php?action=logout">退出</a></li>
				</ul>
				<h3 class="text-muted" align="left">修改密码</h3>
			 </div><hr>
HTML;
			if(isset($_POST['newpassword'])&&isset($_POST['password'])){
				$password=md5(daddslashes($_POST['password']));
				$newpassword=md5(daddslashes($_POST['newpassword']));
				$newrepass=md5(daddslashes($_POST['newrepass']));
				$id=$result[id];
				$username=$result[username];
				if($pwd!=$result[password]){
					echo '原密码错误!3秒后重新修改...<br />若无法跳转请<a href="index.php?action=setpwd">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php?action=setpwd">';
				}elseif(strlen($newpassword) < 6){
					echo '密码长度不符合规定!3秒后重新修改...<br />若无法跳转请<a href="index.php?action=setpwd">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php?action=setpwd">';
				}elseif($newpassword!=$newrepass){
					echo '两次密码不一样!3秒后重新修改...<br />若无法跳转请<a href="index.php?action=setpwd">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php?action=setpwd">';
				}else{

					$newdsql = "UPDATE `w_user` SET `pwd`='{$newpassword}' WHERE id='{$id}' AND username='{$username}'";
					$newpwd = $db->exec($newdsql);
					if($newpwd){
						setcookie("w_user", "", time()-3600*24*30);
						setcookie("w_userid", "", time()-3600*24*30);
						echo '修改成功！请重新登陆！3秒后重新修改...<br />若无法跳转请<a href="login.php?user='.$username.'">点击这里进入</a><meta http-equiv="refresh" content="3;url=login.php?user='.$username.'">';
					}else echo '修改失败！3秒后重新修改...<br />若无法跳转请<a href="index.php?action=setpwd">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php?action=setpwd">';
				}
			}else{
			echo <<<HTML
			 <h3 class="form-signin-heading">修改密码</h3>
			 <form action="index.php?action=setpwd" class="form-sign" method="post">
			 用户名:<br><input type="text" class="form-control" value="{$result[username]}" disabled=ture><br>
			 原密码:<br><input type="text" class="form-control" name="password" value=""><br>
			 新密码:<br><input type="text" class="form-control" name="newpassword" value=""><br>
			 重复密码:<br><input type="text" class="form-control" name="newrepass" value=""><br>
			 <input type="submit" class="btn btn-primary btn-block" name="submit" value="确认修改">
			 </form>
HTML;
			}
				include ('include/foot.php');
				exit;
			}
			
			
		//
		if($_GET['action'] == "setinfo"){
			echo <<<HTML
			<div class="header">
				<ul class="nav nav-pills pull-right" role="tablist">
					<li role="presentation" class="active"><a href="index.php">首页</a></li>
					<li role="presentation"><a href="index.php?action=my">用户中心</a></li>
					<li role="presentation"><a href="login.php?action=logout">退出</a></li>
				</ul>
				<h3 class="text-muted" align="left">修改资料</h3>
			 </div><hr>
HTML;
			$email=substr_replace($result[email],'***','1','3');
			$id=$result[id];
			$username=$result[username];
			if(isset($_POST['qq'])&&isset($_POST['tel'])){
				$qq=daddslashes($_POST['qq']);
				$tel=daddslashes($_POST['tel']);
					$infosql = "UPDATE `w_user` SET `qq`='{$qq}',`tel`='{$tel}' WHERE id='{$id}' AND username='{$username}'";
					$info = $db->exec($infosql);
					if($info){
						echo '修改成功！请重新登陆！3秒后重新修改...<br />若无法跳转请<a href="index.php?action=my">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php?action=my">';
					}else echo '修改失败！3秒后重新修改...<br />若无法跳转请<a href="index.php?action=setinfo">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php?action=setinfo">';
			}else{
				echo <<<HTML
				 <h3 class="form-signin-heading">修改资料</h3>
				 <form action="index.php?action=setinfo" class="form-sign" method="POST">
				 用户ID:<br><input type="text" class="form-control" value="{$result[id]}" disabled=ture><br>
				 电子邮箱: <br><input type="text" class="form-control" value="{$email}" disabled=ture><br>
				 用户名:<br><input type="text" class="form-control" value="{$result[username]}" disabled=ture><br>
				 QQ号码:<br><input type="text" class="form-control" name="qq" value=""><br>
				 手机号码:<br><input type="text" class="form-control" name="tel" value=""><br>
				 <input type="submit" class="btn btn-primary btn-block" name="submit" value="确认修改">
				 </form>
HTML;
			}
				include ('include/foot.php');
				exit;
		}
		
		
		//
		if(($_GET['action'] == "pc"||$_GET['action'] == "on"||$_GET['action'] == "off")&&isset($_GET['id'])){
			$d=daddslashes($_GET['d']);
			$qq=daddslashes($_GET['qq']);
			$gqid=daddslashes($_GET['id']);
			$id=$result[id];
			$action=($_GET['action']=="on")?1:0;
			if($_GET['action']=="pc") $action=2;
				$dsql = "UPDATE `w_qq` SET `{$d}`='{$action}' WHERE (gqid='{$gqid}' AND qq='{$qq}') AND id='{$id}'";
				$do = $db->exec($dsql);
				
		}
		
		if($_GET['action'] == "del" &&isset($_GET['id'])){
			$qq=daddslashes($_GET['qq']);
			$gqid=daddslashes($_GET['id']);
			$id=$result[id];
				$delsql = "DELETE FROM `w_qq` WHERE (gqid='{$gqid}' AND qq='{$qq}') AND id='{$id}'";
				$del = $db->exec($delsql);
				
		}
		if($_GET['action'] == "kpl" &&isset($_GET['id'])){
			$qq=daddslashes($_GET['qq']);
			$gqid=daddslashes($_GET['id']);
			$pldata=daddslashes($_POST['pldata']);
			$id=$result[id];
				$dsql = "UPDATE `w_qq` SET `pl`='1',pldata='$pldata' WHERE (gqid='{$gqid}' AND qq='{$qq}') AND id='{$id}'";
				$do = $db->exec($dsql);
				
		}
		
		if($_GET['action'] == "shop"){
			$m=10;
			$y=100;
			$id=$result[id];
			$rmb=$result[rmb];
			$vipt=time_data($result[viptime]);
			$viptime=($result[vip]!=100)?time_data($result[viptime]+$result[vip]*86400*30):"永久";
			$vipday=($result[vip]!=100)?"$result[vip]个月":"永久";
			echo '<div class="header">
        <ul class="nav nav-pills pull-right" role="tablist">
        <li role="presentation" class="active"><a href="index.php">首页</a></li>
		<li role="presentation"><a href="index.php?action=my">用户中心</a></li>
		<li role="presentation"><a href="login.php?action=logout">退出</a></li>
        </ul>
        <h3 class="text-muted" align="left">自助购买</h3>
      </div><hr>';
		if(isset($_POST['gtime'])){
			$gtime=daddslashes($_POST['gtime']);
			$nrmb=($gtime!=100)?$rmb-$gtime*$m:$rmb-$y;
			$newtime=time();
			$viptime1=$result[viptime]+$result[vip]*86400*30;
			$htime=$result[vip]+$gtime;
			if($nrmb>=0){
				$sql = ($newtime>$viptime1)?"UPDATE `w_user` SET `rmb`='{$nrmb}',`vip`='{$gtime}',`viptime`='{$newtime}' WHERE id='{$id}'":"UPDATE `w_user` SET `rmb`='{$nrmb}',`vip`='{$htime}' WHERE id='{$id}'";
				$do = $db->exec($sql);
				echo '购买成功！3秒后...<br />若无法跳转请<a href="index.php?action=shop">点击这里进入</a><meta http-equiv="refresh" content="3;url=index.php?action=shop">';
			}else{
				echo "余额不足联系管理员充值";
			}
		}else{	
			echo <<<HTML
	  <p>尊敬的客户，你好。你的余额 [<span style="color:red">{$rmb}</span>]</p>
	  <form action="index.php?action=shop" class="form-sign" method="post">
	 购买会员<br>
	 <small style="color:blue">已到期账户从此刻往后延长时间/未到期账户会自动续期</small><br>
	  <select class="form-control" name="gtime">
	  <option value="1">1个月(10元)</option>
	  <option value="2">2个月(20元)</option>
	  <option value="3">3个月(30元)</option>
	  <option value="4">4个月(40元)</option>
	  <option value="5">5个月(50元)</option>
	  <option value="6">6个月(60元)</option>
	  <option value="100">永久(100元)</option>
	  </select><br>
	  <input type="submit" class="btn btn-primary btn-block" name="submit" value="购买">
	  </form>
	  <hr>
	  <p>
	  <div class="row">
	  <table class="table table-bordered">
	  <thead>
	  <tr>
		  <td>购买日期</td>
		  <td>到期日期</td>
		  <td>时间</td>
	  </tr>
	  </thead>
	  <tbody>
	  <tr>
		  <td>{$vipt}</td>
		  <td>{$viptime}</td>
		  <td>{$vipday}</td>
	  </tr>
	  </tbody>
	  </table>
	  </div></p>
HTML;
		}
		
		include ('include/foot.php');
				exit;	
		}
		
		//
		$id=$result[id];
		$rmb=$result[rmb];
		
		$lsql = "SELECT * FROM `w_qq` WHERE id='{$id}'";
		$lsth = $db->query($lsql);
		$list = $lsth->fetchAll();
		$list_num=count($list);
		
		//print_r($list);
		if($list_num!=0){
			foreach ($list as $key=>$value) {

				$key=$key+1;
				$sidzt=$value[sidzt]?'<font color=red>SID失效</font>':'SID正常';
				$skeyzt=$value[skeyzt]?'<font color=red>SKEY失效</font>':'SKEY正常';
				$gq=on_off($value[gq],"gq",$value[qq],$value[gqid]);
				if($value[dz]==1){
					$dz="触屏版<a href='index.php?action=pc&d=dz&qq={$value[qq]}&id={$value[gqid]}'><span class='label label-primary'>PC</span></a>&nbsp;<a href='index.php?action=off&d=dz&qq={$value[qq]}&id={$value[gqid]}'><span class='label label-default'>关闭</span></a>";
				}elseif($value[dz]==2){
					$dz="PC版<a href='index.php?action=on&d=dz&qq={$value[qq]}&id={$value[gqid]}'><span class='label label-primary'>触屏</span></a>&nbsp;<a href='index.php?action=off&d=dz&qq={$value[qq]}&id={$value[gqid]}'><span class='label label-default'>关闭</span></a>";
				}else{
					$dz="已关闭<a href='index.php?action=pc&d=dz&qq={$value[qq]}&id={$value[gqid]}'><span class='label label-primary'>PC</span></a>&nbsp;<a href='index.php?action=on&d=dz&qq={$value[qq]}&id={$value[gqid]}'><span class='label label-primary'>触屏</span></a>";
				}
				if($value[pl]==1){
					$pl="已开启<a href='index.php?action=off&d=pl&qq={$value[qq]}&id={$value[gqid]}'><span class='label label-default'>点击关闭</span></a>";
				}else{
					$pl="已关闭<a href='index.php?action=onpl&d=dz&qq={$value[qq]}&id={$value[gqid]}'><span class='label label-primary'>点击开启</span></a>";
				}
				//$sdel=on_off($value[sdel],"sdel",$value[qq],$value[gqid]);
				$tr .= '<tr>
							<td><span class="label label-warning">'.$key.'</span></td>
							<td><a href="index.php?action=online"><span class="label label-success">在线功能</span></a></td>
							<td><a href="./include/add.php?qq='.$value[qq].'&sid='.$value['sid'].'&skey='.$value['skey'].'"><span class="label label-info">配置</span></a></td>
							<td><a href="index.php?action=del&id='.$value[gqid].'&qq='.$value[qq].'"><span class="label label-danger">删除</span></a></td>
						</tr>
						
						<tr>
							<td></td>
							<td>
								<ul class="list-group">
								<li class="list-group-item active">'.$value[qq].'</li>
								<li class="list-group-item"><a href="http://ish.z.qq.com/infocenter_v2.jsp?B_UID='.$value[qq].'&sid='.$value['sid'].'"><img src="http://q1.qlogo.cn/g?b=qq&nk='.$value[qq].'&s=100&t='.time().'" width="50" height="50" /></a></li>
								<li class="list-group-item">'.$sidzt.'</li>
								<li class="list-group-item">'.$skeyzt.'</li>
                                <li class="list-group-item"><a href="http://m.qzone.com/infocenter?sid='.$value['sid'].'&g_ut=3&g_f=6676">访问空间</a></li>
							</td>
							<td colspan="2">
								<ul class="list-group">
								<li class="list-group-item">挂Ｑ服务:'.$gq.'</li>
								<li class="list-group-item">点赞服务:'.$dz.'</li>';
							if($_GET['action']=='onpl'){
								$tr.='<li class="list-group-item">评论内容:<form action="index.php?action=kpl&qq='.$value[qq].'&id='.$value[gqid].'" method="post"><input type="text" name="pldata" value="'.$value['pldata'].'"></li>
								<li class="list-group-item">评论服务:<input type="submit" value="确认开启" class="label-primary"></li></form>';
							}else{
								$tr.='<li class="list-group-item">评论服务:'.$pl.'</li></form>';
							}
								$tr.='</ul>
							</td>
						</tr>';
			}
		}else{
			$tr='<tr>
					<td colspan="4">
						<div align="center" color="red">
						 你还没有添加任何挂机！
						</div>
					</td>
				</tr>';
		}
		echo <<<HTML
		{$ex}
<!-- Modal -->
<div class="modal fade" align="left" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">平台大银幕公告</h4>
      </div>
      <div class="modal-body">
		{$tc}
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
	<ul class="nav nav-pills" role="tablist">
	<li role="presentation" class="active">
	<a href="./include/getsid.php?action=getsid">添加挂机 <span class="badge">{$list_num}</span></a>
	</li>
	<li role="presentation"><a href="index.php?action=shop">账户余额 <span class="badge">{$rmb}</span></a>
	</li>
	</ul>
<p>
<div class="row">

   

	<table class="table table-bordered">
	<thead>
		<tr>
			<th>#</th>
			<th>状态</th>
			<th colspan="2">挂机服务</th>
		</tr>
	</thead>
	<tbody>
		{$tr}
	</tbody>
	</table>
	
</div>
</p>
	<div class="row">
         <div class="panel panel-primary">
            <div class="panel-heading">
              <h3 class="panel-title">平台通知</h3>
            </div>
            <div class="panel-body" align="left">
			<p><a data-toggle="modal" data-target="#myModal" class="btn btn-default btn-block">查看弹窗大银幕公告</a></p>
			<p style="color:red">{$pttz}</p>
            </div>
          </div>
	</div>

HTML;
include ('include/foot.php');
		exit;
	}
}else{
include ('include/index_js.php');
	echo <<<HTML
	    <div class="header">
        <ul class="nav nav-pills pull-right" role="tablist">
          <li role="presentation" class="active"><a href="index.php">首页</a></li>
          <li role="presentation"><a href="login.php">会员登录</a></li>
          <li role="presentation"><a href="reg.php">注册</a></li>
        </ul>
        <h3 class="text-muted" align="left">体验中心</h3>
      </div><hr>
{$index1}{$index2}{$index3}{$index4}
HTML;
include ('include/foot.php');
    exit;
}